/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package com.ditt.swing;

import java.awt.event.ActionEvent;
import java.text.DateFormat;
import java.util.Date;
import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JOptionPane;

/**
 *
 * @author attobra
 */
public class HeureAvecClasseAnonyme {
    
     public static void main(String[] args){
        
        JFrame fenetre = new JFrame("Quelle heure est il ?");
        
        
        javax.swing.JButton btnHeure = new  JButton("heure actuel");
        
        btnHeure.addActionListener(new ListenerHeure(){
            
               public void actionPerformed(ActionEvent e){
                 DateFormat formatHeureJour = DateFormat.getDateTimeInstance();
                 String heure = formatHeureJour.format(new Date());     
                 JOptionPane.showMessageDialog(null, heure);

                }
            
        });
        
        
        java.awt.Container panneau  = fenetre.getContentPane();
        
        panneau.add(btnHeure);
        
        fenetre.pack();
        fenetre.setSize(300,200);
        
        fenetre.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
        
        fenetre.setVisible(true);
        
        
        
    }
    
}
